package controller

import (
	"hft/Database/admin"
	"hft/Http/Models/request"
	services "hft/Http/Services"
	utils "hft/Http/Utils"

	"github.com/gin-gonic/gin"
)

type SellStatus struct{}

func (*SellStatus) CreateStatus(c *gin.Context) {
	var status *admin.SellStatus

	c.ShouldBindJSON(&status)

	err := services.SellStatusService.CreateStatus(status)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

func (*SellStatus) EditStatus(c *gin.Context) {

	var status *admin.SellStatus

	c.ShouldBindJSON(&status)

	err := services.SellStatusService.EditStatus(status)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

func (*SellStatus) GetStatusList(c *gin.Context) {

	list, err := services.SellStatusService.GetStatusList()

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.OkWithData(list, c)

}

func (*SellStatus) Delete(c *gin.Context) {

	var IDS *request.IDS

	c.ShouldBindJSON(&IDS)

	err := services.SellStatusService.Delete(IDS.IDS)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

var SellStatusController = new(SellStatus)
